#ifndef __WORDSEGMENTATION_HPP__
#define __WORDSEGMENTATION_HPP__

#include "../include/cppjieba/Jieba.hpp"
#include "SplitTool.hpp"

#include <iostream>
#include <string>
#include <vector>

using std::cout;
using std::endl;
using std::string;
using std::vector;

//正常g++ xxx.cc编译即可
//coredump 是因为下面的文件路径不对
const char* const DICT_PATH = "../include/cppjieba/dict/jieba.dict.utf8";
const char* const HMM_PATH = "../include/cppjieba/dict/hmm_model.utf8";
const char* const USER_DICT_PATH = "../include/cppjieba/dict/user.dict.utf8";
const char* const IDF_PATH = "../include/cppjieba/dict/idf.utf8";
const char* const STOP_WORD_PATH = "../include/cppjieba/dict/stop_words.utf8";

class CppJieba
:public SplitTool
{
public:
    CppJieba()
        : _jieba(DICT_PATH, HMM_PATH, USER_DICT_PATH,IDF_PATH,STOP_WORD_PATH)//初始化Jieba类对象
    {
        cout << "cppjieba init!" << endl;
    }

    vector<string> cut(string &str) override//返回str的分词结果
    {
        vector<string> words;
        _jieba.Cut(str, words);
        return words;
    }
private:
    cppjieba::Jieba _jieba;
};

#endif
